package com.semanticweb.webapp.model.ontology;

import org.apache.lucene.document.Document;

import com.semanticweb.webapp.ontology.CType;
import com.semanticweb.webapp.ontology.OntHelper;
import com.semanticweb.webapp.search.IDocument;
import com.semanticweb.webapp.search.SearchMD;

/**
 * Class which represents 'Opis' from the chart.
 * 
 * @author Lab
 * 
 */
public class Description extends DefaultAbstractEntity<String> implements IDocument {

    public static final String ONT_IDENTIFER = "description";

    public Description(final String id) {
        super(id);
    }

    @Override
    public void toRDF() {
        OntHelper.toRDFNote(this.id, this.value, ONT_IDENTIFER, CType.DESCRIPTION);
    }

    public void fromRDF() {
        this.value = OntHelper.fromRDFNote(this.id, CType.DESCRIPTION);
    }

    @Override
    public void toIndexDocument(final Document doc) {
        if (this.value != null) {
            doc.add(SearchMD.DESCRIPTION.createField(this.value));
            doc.add(SearchMD.CONTENT.createField(this.value));
        }
    }

}
